         {in  name="o_type" value="1"}
          <li>
            <label id="paymentTxt">客户承担费用:</label>
            <input type="text" id="user_cd_price" class="ui-input" value="0">&emsp;
          </li>
         {/in}
         <li>
            <label id="paymentTxt">
              {in  name="o_type" value="1"}本次收款:{/in}
              {in  name="o_type" value="4"}本次付款:{/in}
              {in  name="o_type" value="5,2"}本次退款:{/in}
            </label>
            <input type="text" id="payment" class="ui-input" {if condition='!isset($info.payment)'} value="0" {else/} value="{$info.payment}"{/if} onblur="onchange_payment();">&emsp;
        </li>
        {include file="admin@public/account" /}
        <li>
        <label>
         本次欠款:
        </label>
          <input type="text" id="arrears" class="ui-input ui-input-dis" {if condition='!isset($info.arrears)'} value="0.00" {else/} value="{$info.arrears}"{/if} onchange="onchange_arrears()" disabled>
        </li>
        <li>
        
          {in  name="o_type" value="1"}<label>累计欠款:</label> <input type="text" id="total_arrears" class="ui-input ui-input-dis" {if condition='!isset($info.total_arrears)'} value="0.00" {else/} value="{$info.total_arrears}"{/if}   onchange="total_arrears()" disabled>{/in}
          {in  name="o_type" value="4,5"}<label>总欠款:</label> <input type="text" id="total_arrears" class="ui-input ui-input-dis" {if condition='!isset($info.total_arrears)'} value="0.00" {else/} value="{$info.total_arrears}"{/if}   onchange="total_arrears()" disabled>{/in}
        
         
        </li>

        {in  name="o_type" value="1,2"}
         <li>
            <label>销售费用:</label>
            <input type="text" id="saler_user_price" class="ui-input ui-input-dis" value="0" disabled>
        </li>
        {/in}
        {in  name="o_type" value="4,5"}
        <li>
          <label>采购费用:</label>
          <input type="text" id="purchase_cost" class="ui-input ui-input-dis" data-ref="discountRate" disabled
            placeholder="0.00">
          <a id="expenseInfo" class="ui-icon ui-icon-folder-open"></a>
        </li>
        {/in}
       
        <li>
          <a id="doExpense" onclick="doExpense();" class="ui-btn" style="height:27px;">分摊</a>
          <a id="expenseList" style="display:inline-block;height:27px;padding-top:7px;text-decoration:underline;"
            tabid="jine" data-right="FEEBILL_QUERY" tabTxt="采购销售费用清单" parentOpen="true" rel="pageTab"
            _href="/scm/purchasesaleslist/index.html">采购销售费用清单</a>
        </li>
        <script type="text/javascript">
        //本次付款
        function onchange_payment() {
          var total_prices = $("#grid").getCol('total_price', false, 'sum');//实付金额
          ///var arrears1 = $("#arrears").val();//本次欠款1
          var payment = $("#payment").val();//本次付款
          var total_arrears1 = $("#total_arrears").val();//总欠款1-1
          var arrears=(parseFloat(total_prices)-parseFloat(payment)).toFixed(2);//本次欠款
          var total_arrears=(parseFloat(arrears)+parseFloat(total_arrears1)).toFixed(2);//总欠款1-2
          $("#arrears").val(arrears);
          $("#total_arrears").val(total_arrears);
        }
      </script>
      <script type="text/javascript">
        // 采购费用
  function expenseInfoFun(url, obj) {
    var o = $(obj);
    layer.open({
      type: 2,
      title: "采购费用",
      shadeClose: true,
      shade: 0.3,
      maxmin: false, //开启最大化最小化按钮
      area: ['650px', '400px'],
      fixed: false, //不固定
      btn: ['确定', '取消'],
      //btn: ['btn1','btn2'],
      content: url,
      btn1: function (index, layero) {
        var body = layer.getChildFrame('body', index);
        // body.find('#grid').jqGrid('getGridParam', 'data').trigger("reloadGrid");

        // 刷新表格值
        body.find("#reloadTable").click();

        var gridData = body.find('#grid').jqGrid('getGridParam', 'data');
        let arraydata = gridData;
        gridData = JSON.stringify(gridData);
        localStorage.setItem("purchase_data", gridData)

        var discount = 0;
        for (let index = 0; index < arraydata.length; index++) {
          const element = arraydata[index];
          discount = parseFloat(discount / 1 + element.money / 1).toFixed(2);
        }
        $('#purchase_cost').val(discount);
        layer.close(index);
        // var obj = body.find('#grid');
        // var gridData = getJQAllData(obj);
        // var supplierid = body.find('input[name="goodid"]:checked').val();

        // if (supplierid == '' || supplierid == null) {
        //   layer.msg("请选择供应商");
        //   return false;
        // } else {
        //   //获取商品信息
        //   $.get("/admin/basic/one_customer.html", { id: supplierid }, function (data, state) {
        //     if (data.status == 1) {
        //       $("#customer input").val(data.info.sn + " " + data.info.name);
        //       $('#supplierid').val(data.info.id);
        //       layer.close(index);
        //     } else {
        //       layer.msg("获取商品信息失败");
        //     }
        //   })
        // }
        // layer.close(index);
        return false;
      },
      btn2: function (index, layero) {
        layer.close(index);
        return false;
      }
    })
  }

  // 分摊采购费用
  function doExpense() {
    var purchase_cost = $('#purchase_cost').val();
    var data = getJQAllData($("#grid"));
    var total = 0;
    for (let index = 0; index < data.length; index++) {
      const element = data[index];
      total = total / 1 + element['total_price'] / 1;
    }
    for (let index = 0; index < data.length; index++) {
      const element = data[index];
      $("#grid").jqGrid("setCell", element['id'], 'purchase_cost', parseFloat(element['total_price'] / 1 / total * purchase_cost).toFixed(2));
    }
  }
        
      </script>